Retrofit+RxJava实战日志(1)-在Android Studio中配置

在build.gradle中添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//加入retrolambda需要的plugin声明
apply plugin: 'me.tatarka.retrolambda'
//retrolambda的编译路径依赖
buildscript {
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
}
}
//让IDE使用用Java8语法解析
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
//编译RxJava
compile 'io.reactivex:rxjava:1.0.14'
//编译RxAndroid
compile 'io.reactivex:rxandroid:1.0.1'
//编译Retrofit及其相关库,包括Gson
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
compile 'com.google.code.gson:gson:2.4'

Retrolambda是借用Java8的语法特性,需要配置好Java8
安装好Java8后在File > Project structure > SDK Location中配置Java8路径